package day7.homework3;

public class StudentBiz {
    private Student[] students;

    public void init(int count) {
        students = new Student[count];
    }

    public boolean add(Student student) {
        if(students == null) return false;
        int i = 0;
        for (; i < students.length; i++) {
            if(students[i] == null) break;
        }
        if(i == students.length) return false;
        students[i] = student;
        return true;
    }

    public Student search(String name) {
        for (Student student : students) {
            if(student == null) return null;
            if(student.getName().equals(name)) return student;
        }
        return null;
    }

    public void print() {
        for (Student student : students) {
            if(student == null) break;
            System.out.println(student);
        }
    }

}
